home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / geom / geomfix < prev    next >
Text File  |  1993-01-11  |  3KB  |  157 lines

  1. #! /bin/sh
  2. #
  3. # This is geomfix, Copyright 1992 Silvio Levy
  4. # $Header: /a/tampa/h/tampa_a/fac/levy/texts/geombook/RCS/geomfix,v 1.1 92/07/17 13:27:45 levy Exp $
  5. #
  6. # This shell file reads stdin (or any list of files) and adds a header
  7. # similar to the one added by psfix, but without any of the definitons.
  8. # It also abbreviates certain PostScript commands.
  9.  
  10. # Defaults:
  11. lmargin=1.0        # default left margin: .5 inches
  12. rmargin=1.0        # default right margin: .5 inches
  13. bmargin=1.0        # default bottom margin: .5 inches
  14. tmargin=1.0        # default top margin: .5 inches
  15. width=8.5        # default page width: 8.5 inches
  16. height=11        # default page height: 11 inches
  17. transform=''        # default transformation: identity
  18. nodistort=true        # default no-stretching: no
  19. fixwid=false        # default fixwid compensation
  20. fixdash=false        # default fixdash compensation
  21. while :; do
  22.     case $# in
  23.     0)
  24.         break 2
  25.         ;;
  26.     esac
  27.     case "$1" in
  28.     -lmarg)
  29.         shift
  30.         lmargin=$1
  31.         shift
  32.         ;;
  33.     -rmarg)
  34.         shift
  35.         rmargin=$1
  36.         shift
  37.         ;;
  38.     -bmarg)
  39.         shift
  40.         bmargin=$1
  41.         shift
  42.         ;;
  43.     -tmarg)
  44.         shift
  45.         tmargin=$1
  46.         shift
  47.         ;;
  48.     -width)
  49.         shift
  50.         width=$1
  51.         shift
  52.         ;;
  53.     -height)
  54.         shift
  55.         height=$1
  56.         shift
  57.         ;;
  58.     -land)
  59.         tmp=$width
  60.         width=$height
  61.         height=$tmp
  62.         transform="90 rotate 0 Mheight neg translate"
  63.         shift
  64.         ;;
  65.     -stretch)
  66.         nodistort=false
  67.         shift
  68.         ;;
  69.     -stringfix)
  70.         fixwid=false
  71.         shift
  72.         ;;
  73.     -dashfix)
  74.         fixdash=false
  75.         shift
  76.         ;;
  77.     -*)
  78.         echo \
  79. 'Usage: psfix [-lmarg inches] [-rmarg inches] [-bmarg inches] [-tmarg inches]
  80.                           [-land] [-stretch] [-width inches] [-height inches] 
  81.                                   [-stringfix] [-dashfix] [file...]' \
  82.             >&2
  83.         exit 1
  84.         ;;
  85.     *)
  86.         break 2
  87.         ;;
  88.     esac
  89. done
  90.  
  91. # Output header
  92. echo '%!PS-Adobe-2.0 EPSF-2.0'
  93. # Compute bounding box
  94. (
  95. bc <<!
  96. $width * 72
  97. $height * 72
  98. !
  99. ) | (
  100.     read right
  101.     read top
  102.     echo "%%BoundingBox: 0 0 $right $top"
  103. )
  104. cat <<'!'
  105. %%Creator: Mathematica
  106. %%EndComments
  107. !
  108.  
  109. # Output default values
  110. sed 's/[     ]*%.*$//
  111. s/^[     ]*//
  112. /^[     ]*$/d' <<!
  113.  
  114. MyDict begin
  115. /Mlmarg        $lmargin 72 mul def    % left margin (points)
  116. /Mrmarg        $rmargin 72 mul def    % right margin (points)
  117. /Mbmarg        $bmargin 72 mul def    % top margin (points)
  118. /Mtmarg        $tmargin 72 mul def    % bottom margin (points)
  119. /Mwidth        $width 72 mul def    % total page width (points)
  120. /Mheight    $height 72 mul def    % total page height
  121. /Mtransform    { $transform } bind def    % possible page rotation
  122. /Mnodistort    $nodistort def        % no-stretching flag
  123. /Mfixwid    $fixwid    def        % fixedwidth font only flag
  124. /Mfixdash    $fixdash def        % fixeddash flag
  125. /Mrot        0    def        % angle at which text is rendered
  126. !
  127.  
  128. # Some of the following abbrevs were used by me 
  129. # prior to version 2.1 to save space.
  130. # In version 2.1 different abbrevs were introduced.  
  131. # Only k causes a conflict.
  132.  
  133. sed '/^%!$/d
  134. s/^0\.\([0-9]\)/.\1/
  135. s/\([ -]\)0\.\([0-9]\)/\1.\2/g
  136. s/\<k\>$/setcmykcolor/
  137. s/\<Mabswid\>$/Ma/g
  138. s/\<arc\>$/a/g
  139. s/\<curveto\>$/c/g
  140. s/\<setdash\>$/d/g
  141. s/\<fill\>$/f/g
  142. s/\<setgray\>$/g/g
  143. s/\<grestore\>$/gr/g
  144. s/\<gsave\>$/gs/g
  145. s/\<stroke\>$/k/g
  146. s/\<lineto\>$/l/g
  147. s/\<setlinewidth\>$/lw/g
  148. s/\<moveto\>$/m/g
  149. s/\<newpath\>$/n/g
  150. s/\<setrgbcolor\>$/r/g
  151. /^%%Creator:/d' $@
  152.  
  153. echo end
  154.  
  155.  
  156.  
  157.